object Main {  
  def main(args: Array[String]): Unit = {  
    // 示例列表  
    val numbers = List(1, 2, 3, 4, 5)  
  
    // 使用addOne函数  
    val incrementedNumbers = addOne(numbers)  
    println(s"Incremented numbers: $incrementedNumbers")  
  
    // 使用filterEven函数  
    val evenNumbers = filterEven(numbers)  
    println(s"Even numbers: $evenNumbers")  
  
    // 自定义映射函数和归约函数  
    val mapFunc: Int => Int = x => x * 2  
    val reduceFunc: (Int, Int) => Int = (a, b) => a + b  
  
    // 使用mapReduce函数  
    val mappedAndReduced = mapReduce(numbers, mapFunc, reduceFunc)  
    println(s"Mapped and reduced: $mappedAndReduced")  
  }  
  
  // addOne函数：使用map高阶函数给列表中的每个整数加1  
  def addOne(numbers: List[Int]): List[Int] = {  
    numbers.map(_ + 1)  
  }  
  
  // filterEven函数：使用filter高阶函数筛选出偶数  
  def filterEven(numbers: List[Int]): List[Int] = {  
    numbers.filter(_ % 2 == 0)  
  }  
  
  // mapReduce函数：使用map和reduceLeft高阶函数  
  def mapReduce[A, B](numbers: List[A], mapFunc: A => B, reduceFunc: (B, B) => B): B = {  
    numbers.map(mapFunc).reduceLeft(reduceFunc)  
  }  
}